package kechengsheji;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;

public class GenerateGraph {
	public final static int INFINITY = Integer.MAX_VALUE;

	public static MGraph generateMGraph() {
		Object vexs[] = { "校门", "一号楼", "二号楼", "三号楼", "四号楼", "食堂","宿舍","图书馆" };
		ArrayList<String> arrayList = new ArrayList<>();
    	try { File file = new File("E:\\filetext\\shuzu.txt"); 
    	InputStreamReader input = new InputStreamReader(new FileInputStream(file));
    	BufferedReader bf = new BufferedReader(input); // 按行读取字符串 
    	String str;
    	while ((str = bf.readLine()) != null) { 
    		arrayList.add(str);
    	}
    	bf.close();
    	input.close(); 
    	} catch (Exception e) {
    		e.printStackTrace(); 
    		} // 对ArrayList中存储的字符串进行处理 
    	int length = arrayList.size();
    	int width = arrayList.get(0).split(" ").length;
    	String array[][] = new String[length][width];
    	int arcs[][] = new int[length][width];
    	for (int i = 0; i < length; i++) { 
    		for (int j = 0; j < width; j++) { 
    			String s = arrayList.get(i).split(" ")[j];
    	array[i][j] =  s; 
    	arcs[i][j]=Integer.parseInt(s);
    	} 
    		} 
		MGraph G = new MGraph(GraphKind.UDG, 8, 10, vexs, arcs);
		return G;
	}
}
